package com.future.mayi.adapter;

import android.content.Context;
import android.graphics.Paint;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;

import com.future.mayi.R;
import com.future.mayi.model.OldGoodsModel;
import com.future.mayi.utils.PriceUtils;

import java.util.List;

/**
 * Created by 周大虎 on 2017/5/25.
 */

public class GoodsInfoAdapter extends CommonAdapter<OldGoodsModel> {


    public GoodsInfoAdapter(Context context, int textViewResourceId, List<OldGoodsModel> objects) {
        super(context, textViewResourceId, objects);
    }

    @Override
    public void convert(ViewHolder helper, final OldGoodsModel model) {
        TextView tvOldMoney = helper.getView(R.id.tv_old_money);
        tvOldMoney.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG);
        tvOldMoney.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);
        if (model == null) return;
        helper.setWebImage(R.id.iv_img, model.getGoods_img());
        helper.setText(R.id.tv_money, PriceUtils.getPriceText(model.getPrice()));
        helper.setText(R.id.tv_title, TextUtils.isEmpty(model.getQuality_name()) ? "" : ("【" + model.getQuality_name() + "】") + model.getGoods_title());
        helper.getView(R.id.tv_drop).setVisibility(model.getIs_sales() == 1 ? View.VISIBLE : View.GONE);
        helper.getView(R.id.tv_fq).setVisibility(model.getIs_sales() == 1 ? View.VISIBLE : View.GONE);

        if (model.getOriginal_cost() <= 0.0d) {
            helper.getView(R.id.tv_old_money).setVisibility(View.GONE);
        } else {
            helper.getView(R.id.tv_old_money).setVisibility(View.VISIBLE);
            helper.setText(R.id.tv_old_money, PriceUtils.getPriceText(model.getOriginal_cost()));
        }


    }

}





